<?php
namespace app\library\driver;
use think\contract\LogHandlerInterface;
use app\model\SystemLog;
use think\Log;

class SqlLogHandler implements LogHandlerInterface {

    public function save(array $log): bool
    {
        // TODO: Implement save() method.
        // 创建日志
        if(isset($log['info'])){
            $level = Log::INFO;
            $systemLog['code'] = $log[$level][0]['code'];
            $systemLog['msg'] = $log[$level][0]['msg'];
            $systemLog['level'] = $level;
            $result = SystemLog::create($systemLog);
            $bool = $result['log_id'] > 0 ? true : false;
            return $bool;
        } else {
            return false;
        }

    }
}
